/*
 * File:   Schwefel.h
 * Author: jcrada
 *
 * Created on 12 November 2010, 11:04 AM
 */

#ifndef ECB_SCHWEFEL2_26_H
#define	ECB_SCHWEFEL2_26_H

#include "ecb/base/Problem.h"

namespace ecb {

    /* Source:
   @book{bf:qings-book,
        author = {Qing, Anyong},
        title = {Differential Evolution: Fundamentals and Applications in Electrical Engineering},
        year = {2009},
        publisher = {Wiley-IEEE Press}}
     */

    class Schwefel2_26 : public Problem {
    public:

        Schwefel2_26(const std::string& id = "Schwefel2_26", const std::string& name = "Schwefel2_26",
                int dimensions = 0, scalar minimum = -500, scalar maximum = 500,
                bool minimization = true) :
        Problem(id, name, dimensions, minimum, maximum, minimization) { }

        scalar f(const std::vector<scalar>& x) {
            scalar sum = 0;
            for (size_t i = 0; i < x.size(); ++i) {
                sum += x[i] * std::sin(std::sqrt(std::fabs(x[i])));
            }
            return -(1.0 / x.size()) * sum;
        }
    };
}


#endif	/* ECB_SCHWEFEL2_26_H */

